/*************************************************************************************************************
*
*
*
***************************************************************************************************************/

/**********************************
* @open index.php
* display the root element 
*********************************************/
function showRootElement(file){
	
	var xmlhttp1;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
	  	if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			var feedback=xmlhttp1.responseText;
			
			document.getElementById('container').innerHTML = feedback;	

		}
	}
	xmlhttp1.open("GET","index.php?f="+file,true);
	xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/********************************************
* open dispSubElement.php 
*Display the sub element of the root one
**********************************************/
function showSubElement(path,element,file){
	
	var xmlhttp1;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
	  	if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{
			element.innerHTML = "-";
			
			//element.setAttribute('onclick',"closeDirectory(this,'"+path+"')");
			
			element.onclick = function (){closeDirectory(this,path,file);return true}
			
			var feedback=xmlhttp1.responseText;
			
			//alert(feedback);
			
			element.parentNode.nextSibling.childNodes.item(1).innerHTML = feedback;
			
			//document.getElementById().onclick= 

		}
	}
	xmlhttp1.open("GET","dispSubElement.php?p="+path+"&f="+file,true);
	xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/***********************************************************
*Close the open directory
***********************************************************/
function closeDirectory(element,path,file){
	
	element.parentNode.nextSibling.childNodes.item(1).innerHTML = "";
	
	element.innerHTML = "+";
	
	//element.setAttribute('onclick',"showSubElement('"+path+"',this)");
	
	element.onclick = function (){showSubElement(path,this,file);return true}
	
}

/*************************************************************
*generate editable form 
*************************************************************/
function generateEditForm(element,path,file){
	
	var content = element.parentNode.parentNode.previousSibling.getElementsByTagName('textarea').item(0).value;
	
	 element.parentNode.parentNode.previousSibling.getElementsByTagName('textarea').item(0).disabled = false;

	//alert(content);
	
	//saveEdittedForm(this,path);return true
	
	//element.parentNode.parentNode.previousSibling.childNodes.item(0).innerHTML = "<textarea>"+content+"</textarea>";
	
	element.parentNode.innerHTML = "<a href=\"javascript:void(0)\" onclick=\"saveEdittedForm(this,'"+path+"','"+file+"')\">save</a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"cancelEditForm(this,'"+path+"','"+file+"')\">cancel</a>";

}

/**************************************************
*
****************************************************/
function saveEdittedForm(element,path,file){
	
	var content = element.parentNode.parentNode.previousSibling.getElementsByTagName('textarea').item(0).value;
	
	var enContent = content;
	
	var xmlhttp1;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
	  	if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{		
			var feedback=xmlhttp1.responseText;
			
			//alert(feedback);
			
			element.parentNode.parentNode.previousSibling.getElementsByTagName('textarea').item(0).disabled = true;
			
			//element.parentNode.parentNode.previousSibling.childNodes.item(0).innerHTML = content;

			element.parentNode.innerHTML = "<a href=\"javascript:void(0)\" onclick=\"generateEditForm(this,'"+path+"','"+file+"')\">edit</a>";
		}
	}
	xmlhttp1.open("GET","saveXmlData.php?p="+path+"&d="+enContent+"&f="+file,true);
	xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
	//document.getElementById().
}

function cancelEditForm(element,path,file){
	
	//element.parentNode.parentNode.previousSibling.childNodes.item(0).innerHTML = element.parentNode.parentNode.previousSibling.childNodes.item(0).childNodes.item(0).innerHTML;
	
	element.parentNode.parentNode.previousSibling.getElementsByTagName('textarea').item(0).disabled = true;

	element.parentNode.innerHTML = "<a href=\"javascript:void(0)\" onclick=\"generateEditForm(this,'"+path+"','"+file+"')\">edit</a>";
}

function openFilesDir(file,module,element){
	
	var xmlhttp1;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
	  	if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{		
			
			var feedback=xmlhttp1.responseText;
			
			element.parentNode.nextSibling.childNodes.item(1).innerHTML = feedback;

			element.onclick = function (){closeFilesDir(file,module,this);return true}
			
			element.innerHTML = "-";
			
			//document.getElementById().parentNode.nextSibling.childNodes.item(1).nodeName
		}
	}
	
	xmlhttp1.open("GET","../ajax/ajaxgetSubDir.php?f="+file+"&module="+module,true);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

function closeFilesDir(file,module,element){
	
	element.innerHTML = "+";
	
	element.onclick = function (){openFilesDir(file,module,this);return true}
	
	element.parentNode.nextSibling.childNodes.item(1).innerHTML = "";
}

function chooseFile(element,path,module){
	
	var len = document.getElementById('dvFileList').getElementsByTagName('a').length;
	
	for(var i=0;i<len;i++){
		
		document.getElementById('dvFileList').getElementsByTagName('a').item(i).style.backgroundColor = '#FFFFFF';
	}
	
	var fileName = element.innerHTML;
	
	document.getElementById('dvImportArea').innerHTML = "<label>"+fileName+"</lable><input type='button' value='Import Files' onclick=\"parseXMLtoDB('"+path+"',this,'"+module+"')\"/><br/><div id=\"dvLoadingZone\" style=\"overflow:scroll;height:400px;width:600px;border-style:solid; border-width:1px;\"></div>";
	
	element.style.backgroundColor = '#00FFFF';
}

/**
*parseXMLtoDB() get content from some xml file and call xml content parsing function
*
*@param path is the path of selected xml file
*@param element is current html element
*
*/
function parseXMLtoDB(path,element,module){
	
	var xmlhttp1;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
	  	if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
					
			var feedback=xmlhttp1.responseText;

			var xmlDoc = loadXMLFile(feedback);
			
			xmlObjectParser(xmlDoc,feedback,module);
		}
	}
	
	xmlhttp1.open("GET","../ajax/ajaxxmltodb.php?fpath="+path,true);
	xmlhttp1.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
}

/**
*xmlObjectParser() is the function which is called by parseXMLtoDB to trigger the xmlIteration function to launch xml import
*
*@param object is the xml document object
*@param path is the path of xml file
*/
function xmlObjectParser(object,path,module){
	
	var len = object.childNodes.length;
	
	var counter = 1;
	
	for(var i=0;i<len;i++){
		
		var element = object.childNodes[i];
		
		if(object.childNodes[i].nodeName != 'xml'){
			
			fpath = "/"+object.childNodes[i].nodeName+"["+i+"]";

			xmlIteration(element,'',path,fpath,counter,0,"root",0,module);
			
			counter ++;
		}
	}
}

/**
*xmlIteration() is the function to launch xml import by using iteration
*
*@param element is element of current xml tag
*@param parent is the parent element of current xml element 
*@param path is the path of current xml file
*
**/
var globalCounter = 0;

function xmlIteration(element,parent,path,fpath,xsort,conLayer,siteparent,sitesort,module){

	var name = element.nodeName;
	
	//alert(path+fpath);
	
	if(name != "#text" && name != "#cdata-section" && name != "#comment"){//
	
		x_id = path+fpath;//tags id

		var lenAtt = element.attributes.length;
		
		if(lenAtt >0){
			
			for(var j=0;j<lenAtt;j++){
				
				if (window.XMLHttpRequest)
				{// code for IE7+, Firefox, Chrome, Opera, Safari
					xmlhttp1=new XMLHttpRequest();
				}
				else
				{// code for IE6, IE5
					xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
				}
				xmlhttp1.onreadystatechange=function()
				{
					if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
					{			
						var feedback=xmlhttp1.responseText;
						document.getElementById('dvLoadingZone').innerHTML += feedback;
						var objdiv= document.getElementById('dvLoadingZone');
						objdiv.scrollTop = objdiv.scrollHeight;
					}
				}
				xmlhttp1.open("GET","../ajax/ajaxxmltagsoperation.php?mode=iatt&id="+escape(x_id)+"&name="+element.attributes[j].nodeName+"&value="+element.attributes[j].nodeValue+"&section="+escape(path)+"&layerdepth="+conLayer+"&xmlmodule="+module,false);
				xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp1.send();
			}
		}
		
		x_name = name;
		
		x_parent = parent;
		
		x_accesstype = 1;
		
		x_statustype = 1;
		
		x_access = 1;
		
		x_created = new Date();
		
		x_status = 1;
		
		x_section = path;
		
		x_sort = xsort;	
		
		x_siteparent = "";
		
		if(x_name == "page" || x_name == "popup" || x_name == "title" || x_name == "text" || x_name == "bullets" || x_name == "instructions" || x_name == "bullet"){
			
			x_siteparent = siteparent;
			
			siteparent = x_id;
			
			//x_sitesort = sitesort;
		}
		
		if(x_name != "section" && x_name != "pages" && x_name != "page" && x_name != "popup"){
			
			x_accesstype = 0;
			x_statustype = 0;
		}
		
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp1=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
			xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp1.onreadystatechange=function()
		{
			if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
			{			
				globalCounter ++;
				
				var callback=xmlhttp1.responseText;
				
				document.getElementById('dvLoadingZone').innerHTML += callback;
				
				var objdiv= document.getElementById('dvLoadingZone');
				
				objdiv.scrollTop = objdiv.scrollHeight;
			}
		}
		
		//alert("../ajax/xml_tags_operation.php?id="+escape(x_id)+"&name="+x_name+"&parent="+escape(x_parent)+"&sort="+xsort+"&section="+escape(x_section));
		xmlhttp1.open("GET","../ajax/ajaxxmltagsoperation.php?mode=itags&id="+escape(x_id)+"&name="+x_name+"&parent="+escape(x_parent)+"&accesstype="+x_accesstype+"&statustype="+x_statustype+"&sort="+xsort+"&section="+escape(x_section)+"&xpath="+escape(fpath)+"&layerdepth="+conLayer+"&siteparent="+x_siteparent+"&sitesort="+globalCounter+"&xmlmodule="+module,false);
		xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
		xmlhttp1.send();

		var lenSubNodes = element.childNodes.length;
		
		var counter = 1;
		
		conLayer++;
	
		for(var i=0;i<lenSubNodes;i++){
			
			var fpathNext = fpath +"/"+element.childNodes[i].nodeName+"["+i+"]";
			
			xmlIteration(element.childNodes[i],path+fpath,path,fpathNext,counter,conLayer,siteparent,i,module);
			
			if(element.childNodes[i].nodeName != "#text" && element.childNodes[i].nodeName != "#comment" && element.childNodes[i].nodeName != "#cdata-section"){
				
				counter++;
			}
		}
	}
	else{
		
		if(name == "#cdata-section" || (element.parentNode.childNodes.length == 1 && name == "#text")){	
		
			var content = element.nodeValue;
				
			if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp1=new XMLHttpRequest();
			}
			else
			{// code for IE6, IE5
				xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp1.onreadystatechange=function()
			{
				if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
				{			
					var feedback=xmlhttp1.responseText;
					document.getElementById('dvLoadingZone').innerHTML += feedback;
					
					var objdiv= document.getElementById('dvLoadingZone');
					objdiv.scrollTop = objdiv.scrollHeight;
				}
			}
			
			xmlhttp1.open("GET","../ajax/ajaxxmltagsoperation.php?mode=ucon&id="+escape(parent)+"&content="+content,false);
			xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
			xmlhttp1.send();
		}
		
	}
}

function loadXMLString(txt) 
{
	if (window.DOMParser)
 	{
  		parser=new DOMParser();
  		xmlDoc=parser.parseFromString(txt,"text/xml");
  	}
	else // Internet Explorer
  	{
  		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  		xmlDoc.async="false";
  		xmlDoc.loadXML(txt); 
  	}
	return xmlDoc;
}

function loadXMLFile(path){
	
	if (window.XMLHttpRequest)
  	{
  		xhttp=new XMLHttpRequest();
  	}
	else // IE 5/6
 	{
  		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xhttp.open("GET",path,false);
	xhttp.send();
	xmlDoc=xhttp.responseXML;
	
	return xmlDoc;
}

/**
*onclickPlusDir() expand dirctory of xml parent
*@param element is the current triggered element
*/
function onclickPlusDir(element,parent,section,lan){
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{			
			var callback=xmlhttp1.responseText;
			
			element.parentNode.nextSibling.childNodes[1].innerHTML = callback;
			
			element.onclick = function (){closePlusDir(this,parent,section,lan);return true}
			
			element.innerHTML = "-";
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxonclickplusdir.php?xmlparent="+parent+"&xmlsection="+section+"&language="+lan,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
}

/**
*closePlusDir() close the open dirctory of xml
*@param element is the current triggered element
*/
function closePlusDir(element,parent,section,lan){
	
	element.parentNode.nextSibling.childNodes[1].innerHTML = "";
	
	element.onclick = function (){onclickPlusDir(this,parent,section,lan);return true}
	
	element.innerHTML = "+";
}

/**
*onmouseoverXMLTags() mouseover current xml tag
*@param element is the current trggered element
*/
function onmouseoverXMLTags(element){
	
	element.style.color = "#5882FA";
}

/**
*onmouseoverXMLTags() mouseout current xml tag
*@param element is the current trggered element
*/
function onmouseoutXMLTags(element){
	
	element.style.color = "#000000";
}

/**
*onclickXMLTags() onclick current xml tag
*@param element is the current trggered element
*/
function onclickXMLTags(element,section,id,lan){
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('xmlcontrolpanel').innerHTML = callback;
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxdisplaycontentpanel.php?xmlsection="+section+"&xmltagid="+id+"&language="+lan,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/**
*onclick_languageform() onclick to generate language creation form 
*
*/
function onclick_languageform(){
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('dvFrame').innerHTML = callback;
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxgeneratelanguageform.php",false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}


/**
*onclick_createNewLan create new language
*
*@param abbre is the language abbreviation
*/
function onclick_createNewLan(element){
	
	var abbre = element.previousSibling.value;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('dvFrame').innerHTML = callback;
			
			if(callback == "True"){
				
				window.location = "../admin/xml_editor.php";
			}
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxcreatenewlanguage.php?languageAbbre="+abbre,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/**
*onclick_selectChoosenLan() select language
*
*@param abbre is the current element
*/
function onclick_selectChoosenLan(element){
	
	var elementValue = element.value;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function()
	{
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
		{			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('xmlcontainer').innerHTML = callback;
			
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxselectlanguageitem.php?language="+elementValue,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/**
*onclick_selectxmlfileexport() select xml file to export
*@param element is the current element
*@param language is the selected language
*
*/
function onclick_selectxmlfileexport(element,language){
	
	var fileName = element.innerHTML
	
	var lenHyper = document.getElementById("dvXmlexporter").getElementsByTagName("a").length;
	
	if(lenHyper == 0){
		
		var dvEpList = document.createElement("div");
		
		dvEpList.setAttribute("id","dvExportList");
		
		var button = document.createElement("input");
		
		button.setAttribute("type","button");
		
		button.setAttribute("onclick","onclick_exportxmlfile(this,'"+language+"')");
		
		button.setAttribute("value","export");
		
		document.getElementById('dvXmlexporter').appendChild(dvEpList);
		
		document.getElementById('dvXmlexporter').appendChild(button);
	}
	
	var flag =false;
	
	for(var i=0;i<lenHyper;i++){
		
		if(document.getElementById("dvXmlexporter").getElementsByTagName("a").item(i).innerHTML == fileName){
			
			flag = true;
		}
	}
	
	if(flag == false){
		
		var newElement = document.createElement("a");
		
		newElement.setAttribute("href","javascript:void(0)");
		
		newElement.setAttribute("onclick","onclick_removecurrentitem(this,'"+language+"')");
	
		newElement.setAttribute("style","display:block;text-decoration:none;");
		
		newElement.appendChild(document.createTextNode(fileName));
		
		document.getElementById('dvExportList').appendChild(newElement);
		
	}
	
	
}

/**
*onclick_removecurrentitem() click current element to remove item on the export lists
*
*@param element is the current element
*@param language is the language of one which is to be exported 
*/
function onclick_removecurrentitem(element,language){
	
	var lenHyper = document.getElementById("dvXmlexporter").getElementsByTagName("a").length;
	
	if(lenHyper != 1){
	
		element.parentNode.removeChild(element);
	}
	else if(lenHyper == 1){
		
		document.getElementById("dvXmlexporter").innerHTML = "";
	}
	
}

/**
*onclick_exportxmlfile() click current element to export xml file
*
*@param element is the current element
*@param language is the language of one which is to be exported 
*/
function onclick_exportxmlfile(element,language){
	
	var lenHyper = document.getElementById('dvExportList').getElementsByTagName("a").length;
	
	var sectionList = ""; //sectionlist is variable to store list of selected sections
	
	for(var j=0; j<lenHyper; j++){
		
		sectionList += document.getElementById('dvExportList').getElementsByTagName("a").item(j).innerHTML+"||";

	}
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){	
				
			var callback=xmlhttp1.responseText;
			
			alert(callback);
			
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxexportxmlfile.php?language="+language+"&&arrxmlsection="+escape(sectionList),false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/**
*onchange_triggerLanguageFilter() onchange to trigger language filter function , call the ajaxpagefilter.php file to get content
*
**/
function onchange_triggerLanguageFilter(){

	var currentLanguage = document.getElementById('selLan').value;
	
	var currentModule = document.getElementById('selModules').value;
	
	var currentStatus = document.getElementById('selStatus').value
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){	
				
			var callback=xmlhttp1.responseText;
			
			document.getElementById('maincontentright').innerHTML = unescape(unescape(callback));
						
			document.getElementById('dvRefreshButton').innerHTML = "<a href=\"javascript:void(0)\" onclick=\"onchange_triggerLanguageFilter()\">Refresh</a>";	
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxpagefilter.php?xmlmode=filter&language="+currentLanguage+"&xmlmodule="+currentModule+"&xmlstatus="+currentStatus,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();

}

/**
*onlick_openSiteParent() onlick to open the directory in site page
*@param element is the current element
*@param id is the id of current page
**/
function onlick_openSiteParent(element,id,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	var parentID = id;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){	
				
			var callback=xmlhttp1.responseText;
			
			element.parentNode.nextSibling.childNodes[1].innerHTML = callback;
			
			element.onclick = function (){closeSiteParent(this,id,section);return true}
			
			element.innerHTML = "-";
			
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxgetsitesubdir.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&parentid="+parentID,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

function closeSiteParent(element,id,section){
	
	element.onclick = function (){onlick_openSiteParent(this,id,section);return true}
	
	element.innerHTML = "+";
	
	element.parentNode.nextSibling.childNodes.item(1).innerHTML = "";
}

/**
*onclick_getSiteContent() onlick to get the site content
*@param element is current element
*@param id the is the id of current page
**/
function onclick_getSiteContent(element,id,flag,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			arrCallback = callback.split("@break;");
			
			var aCount = document.getElementById('tbTagsTree').getElementsByTagName("a").length;
	
			for(var i = 0; i<aCount ; i++ ){
		
				document.getElementById('tbTagsTree').getElementsByTagName("a").item(i).style.backgroundColor = "#FFFFFF";
			}
			
			var tagName = element.innerHTML;
			
			if(flag == false){
				
				document.getElementById('dvContentPanel').innerHTML = "<b>Content:</b><br/>"+unescape(arrCallback[0])+"(EN)<br/>"+unescape(arrCallback[1])+"<br/>";
				
				document.getElementById('dvContentPanel').innerHTML += "<b>Comment:</b><br/><textarea readonly=\"readonly\" cols=\"60\" rows=\"10\">"+unescape(arrCallback[2])+"</textarea>";
			}
			else{
				
				document.getElementById('dvContentPanel').innerHTML = "<b>Content:</b><br/>"+unescape(arrCallback[0])+"(EN)<br/>"+unescape(arrCallback[1])+"<br/>";
				
				document.getElementById('dvContentPanel').innerHTML += "<b>Comment:</b><br/><textarea readonly=\"\" cols=\"60\" rows=\"10\">"+unescape(arrCallback[2])+"</textarea><br/>";
				
				document.getElementById('dvContentPanel').innerHTML += "<a href=\"javascript:void(0)\" onclick=\"onclick_xmlDataEditor('"+id+"','"+tagName+"','"+currentSection+"')\">edit</a>"
			}
							
			element.style.backgroundColor = "#A9D0F5";		
		}
	}
	xmlhttp1.open("GET","../ajax/ajaxgetcontentforsite.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+id,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

//var editorNumber = 0;

var editor;
/**
*onclick_xmlDataEditor() click current element to display data editor popup
*@param id is the id of the site
*@param name is the 
*/
function onclick_xmlDataEditor(id,name,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			var arrCallback = callback.split("@break;");
			
			document.getElementById('modal').style.backgroundColor = "#FFFFFF";
			
			document.getElementById('modal').innerHTML = "ENGLISH Version<br/><textarea  readonly = \"readonly\">"+unescape(arrCallback[0])+"</textarea><br/>";
			
			document.getElementById('modal').innerHTML += "Current Version<br/>";
			
			document.getElementById('modal').innerHTML += "<textarea cols=\"80\" id='editor1' name='editor1' rows=\"10\">"+unescape(arrCallback[1])+"</textarea></br>";
			
			document.getElementById('modal').innerHTML += "COMMENT<br/>";
			
			document.getElementById('modal').innerHTML += "<textarea  id=\"commentEditor\" readonly=\"readonly\" cols=\"60\" rows=\"10\">"+unescape(arrCallback[2])+"</textarea><br/>";
			
			document.getElementById('modal').innerHTML += "<textarea  id=\"dvPreviousCommentEditor\" cols=\"60\" rows=\"10\"></textarea><br/>";
			
			document.getElementById('modal').innerHTML += "<a href=\"javascript:void(0)\" onclick=\"onclick_saveEditContent('editor1','"+id+"','"+name+"','"+section+"')\">save</a>&nbsp;<a href=\"javascript:Popup.hide('modal');CKEDITOR.instances.editor1.destroy();\">close</a>";

			editor = CKEDITOR.replace( "editor1",
				{
					toolbar : [ [ 'Source', '-', 'Bold', 'Italic', 'Underline', '-', 'MyButton' ] ]
				});
	
			Popup.showModal('modal');
			
			editorNumber ++;
		}
	}
	xmlhttp1.open("GET","../ajax/ajaxgetcontentforsite.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+id,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
}

/**
*onclick_changeTagStatus() click current element to change tag status
*@param mode is the mode of changing xml tag status
*@param pageID is the id of page
*@param atrID is the id of attribute
*/
function onclick_changeTagStatus(mode,pageID,atrID,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value;
	
	var statusChangeMode = mode;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('maincontentright').innerHTML = unescape(unescape(callback));
		}
	}
	xmlhttp1.open("GET","../ajax/ajaxgetpagestatustitle.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+escape(pageID)+"&titleid="+escape(atrID)+"&xmlstatusmode="+statusChangeMode,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/**
*onclick_showTitle() show title of a page
*@param element is the current element
*@param pageID is the id of current page
*@param id is the id of title attribute
*/
function onclick_showTitle(element,pageID,id,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('dvContentPanel').innerHTML = unescape(unescape(callback));
			
			var aCount = document.getElementById('tbTagsTree').getElementsByTagName("a").length;
	
			for(var i = 0; i<aCount ; i++ ){
		
				document.getElementById('tbTagsTree').getElementsByTagName("a").item(i).style.backgroundColor = "#FFFFFF";
			}
			
			element.style.backgroundColor = "#A9D0F5";
		}
	}
	xmlhttp1.open("GET","../ajax/ajaxgetpagestatustitle.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+escape(pageID)+"&titleid="+escape(id),false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
//	var aCount = document.getElementById('tbTagsTree').getElementsByTagName("a").length;
//	
//	for(var i = 0; i<aCount ; i++ ){
//		
//		document.getElementById('tbTagsTree').getElementsByTagName("a").item(i).style.backgroundColor = "#FFFFFF";
//	}
//		
//	element.style.backgroundColor = "#A9D0F5";
//	
//	document.getElementById('dvContentPanel').innerHTML = title+"\n<a href=\"javascript:void(0)\" onclick=\"onclick_titleEditor('"+title+"','"+id+"')\">edit</a>";
}

function onclick_titleEditor(tagid, atrributeName,id,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('modal').innerHTML = unescape(unescape(callback));
			
			Popup.showModal('modal');

		}
	}
	xmlhttp1.open("GET","../ajax/ajaxgeneratetitleeditor.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&atrid="+escape(id)+"&siteid="+escape(tagid)+"&atrname="+atrributeName,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
	//document.getElementById('modal').innerHTML = "<textarea cols=\"80\" id='taTitleEditor' rows=\"10\">"+title+"</textarea><br/><a href=\"javascript:void(0)\" onclick=\"onclick_saveTitleEditor('"+id+"')\">save</a>&nbsp;<a href=\"javascript:Popup.hide('modal');\">close</a>";
	
	//Popup.showModal('modal');
}

function onclick_saveTitleEditor(siteID,tagID,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	var data = document.getElementById('taTitleEditor').value;
	
	var comment = document.getElementById('taTitleComment').value;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;

			document.getElementById('dvTitle').innerHTML = unescape(unescape(callback));	
			//".$obTagTitle -> GetAttributeByKey("value")."<a href=\"javascript:void(0)\" onclick = \"onclick_titleEditor('".$currentTag->getID()."','value','".$titleID."')\">Edit</a>
			
			Popup.hide('modal');
		}
	}
	alert(escape(unescape(data)));
	xmlhttp1.open("GET","../ajax/ajaxsaveeditcontent.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&editcontent="+escape(data)+"&editcomment="+escape(comment)+"&tagid="+tagID+"&tagname=title&siteId="+siteID,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

/**
*onclick_saveEditContent() save the editting content
*@param editorID is the identification of editor
*@param tagID is the id of editting tag
*@param name is the name of editting tag
*/
function onclick_saveEditContent(editorID,tagID,name,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	var data = CKEDITOR.instances.editor1.getData();

	var comment = document.getElementById('dvPreviousCommentEditor').value;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
		
			document.getElementById('dvContentPanel').innerHTML = unescape(callback);
			
			CKEDITOR.instances.editor1.destroy();
			
			Popup.hide('modal');

		}
	}
	xmlhttp1.open("GET","../ajax/ajaxsaveeditcontent.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&editcontent="+escape(data)+"&tagid="+tagID+"&tagname="+name+"&editcomment="+comment,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();

}

/**
*onclick_editpagecomment is the function to get the edit page comment and load it with editor
*
*@param id is the id of current tag
*
*/
function onclick_editpagecomment(id,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;

			document.getElementById('modal').innerHTML = callback;
			
			Popup.showModal('modal');
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxsavepagecomment.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+id,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

function onclick_savepagecommentdata(id,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value;
	
	var editComment = document.getElementById('taPageEditor').value;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;

			document.getElementById('dvPageComment').innerHTML = callback;
			
			Popup.hide('modal');
		}
	}

	xmlhttp1.open("GET","../ajax/savepagecommentdata.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+id+"&editcomment="+editComment,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
}

///**
//*onchange_chooseModule() change the dropdown list to change module by calling ../ajax/ajaxgetsections.php file through ajax
//*
//*/
//function onchange_chooseModule(){
//	
//	var currentLanguage = document.getElementById('selLan').value;
//	
//	var currentModule = document.getElementById('selModules').value;
//	
//	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
//	
//		xmlhttp1=new XMLHttpRequest();
//	}
//	else{// code for IE6, IE5
//		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
//	}
//	xmlhttp1.onreadystatechange=function(){
//		
//		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
//			
//			var callback=xmlhttp1.responseText;
//			
//			document.getElementById('selSection').innerHTML = callback;
//		}
//	}
//
//	xmlhttp1.open("GET","../ajax/ajaxgetsections.php?language="+currentLanguage+"&xmlmodule="+currentModule,false);
//	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
//	xmlhttp1.send();
//}

/**
*onclick_addInteraction() is to generate interaction editor
*
*
*/
function onclick_addInteraction(tag_id,section){
	
	document.getElementById('modal').innerHTML = "<div class =\"popup\"><b>New Interaction:<b/><br/><textarea id=\"taInteraction\" cols=\"60\" rows=\"10\"></textarea><br/><a href=\"javascript:void(0)\" onclick=\"onclick_saveInteraction('"+tag_id+"','add','"+section+"')\">Add</a>&nbsp;<a href=\"javascript:void(0)\" onclick=\"Popup.hide('modal')\">Cancel</a></div>";

	Popup.showModal('modal');
}

function onclick_editInteraction(tag_id,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('modal').innerHTML = callback;

			Popup.showModal('modal');
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxgetInteraction.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+tag_id,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();

}

function onclick_saveInteraction(tag_id,mode,section){
	
	var currentLanguage = document.getElementById('selLan').value;
	
	var currentSection = section;
	
	var currentStatus = document.getElementById('selStatus').value;
	
	var interactionData = document.getElementById('taInteraction').value;
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp1=new XMLHttpRequest();
	}
	else{// code for IE6, IE5
		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp1.onreadystatechange=function(){
		
		if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
			
			var callback=xmlhttp1.responseText;
			
			document.getElementById('dvInteraction').innerHTML = callback;
			
			Popup.hide('modal');
		}
	}

	xmlhttp1.open("GET","../ajax/ajaxsaveinteraction.php?xmlmode=section&xmlstatus="+currentStatus+"&language="+currentLanguage+"&xmlsection="+currentSection+"&siteid="+tag_id+"&editcontent="+interactionData+"&mode="+mode,false);
	xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlhttp1.send();
	
}


/**
*onchange_chooseLanguage() is to change dropdownlist index to select language 
*
*
*/
function onchange_chooseLanguage(){
	
	var selectedItem = document.getElementById('selLan').value;
	
	if(selectedItem == '@clearing'){
		
		document.getElementById('selModules').innerHTML = "";
		
		document.getElementById('selStatus').innerHTML = "";
		
		document.getElementById('maincontentright').innerHTML = "";
		
		document.getElementById('dvRefreshButton').innerHTML = "";
	}
	else{
		
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp1=new XMLHttpRequest();
		}
		else{// code for IE6, IE5
			xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp1.onreadystatechange=function(){
		
			if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
				
				var callback=xmlhttp1.responseText;
				
				document.getElementById('selModules').innerHTML = "";
		
				document.getElementById('selStatus').innerHTML = "";
		
				document.getElementById('maincontentright').innerHTML = "";
				
				document.getElementById('dvRefreshButton').innerHTML = "";
				
				document.getElementById('selModules').innerHTML = callback;
			}
		}

		xmlhttp1.open("GET","../ajax/ajaxchooselanguage.php?language="+selectedItem,false);
		xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
		xmlhttp1.send();
	}
}

/**
*onchange_chooseModule() is to change dropdownlist index to select module
*
*
*/
function onchange_chooseModule(){
	
	var selectedItem = document.getElementById('selModules').value;
	
	if(selectedItem == '@clearing'){
		
		document.getElementById('selStatus').innerHTML = "";
		
		document.getElementById('maincontentright').innerHTML = "";
		
		document.getElementById('dvRefreshButton').innerHTML = "";
	}
	else{
		
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp1=new XMLHttpRequest();
		}
		else{// code for IE6, IE5
			xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp1.onreadystatechange=function(){
		
			if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
				
				var callback=xmlhttp1.responseText;
				
				document.getElementById('selStatus').innerHTML = "";
		
				document.getElementById('maincontentright').innerHTML = "";
				
				document.getElementById('dvRefreshButton').innerHTML = "";
				
				document.getElementById('selStatus').innerHTML = callback;

			}
		}

		xmlhttp1.open("GET","../ajax/ajaxchoosemodule.php",false);
		xmlhttp1.setRequestHeader("a", "Sat, 1 Jan 2000 00:00:00 GMT");
		xmlhttp1.send();
	}
}